package yin.com.service.impl;

import yin.com.dao.UserDao;
import yin.com.model.User;
import yin.com.service.Userserver;

import java.util.Map;

public class Userserverimpl implements Userserver {

    private UserDao userDao=new UserDao();

    @Override
    public User findUserByNameAndPwd(String username) {
        return userDao.finUserByName(username);
    }

    @Override
    public Map<String, Object> finduserByID(Integer userId) {
        return userDao.findUserdaoByid(userId);
    }

    @Override
    public User findUserEmail(String email) {
        return userDao.findUserByEmail(email);
    }

    @Override
    public void adduser(String email, String username, String password) {
        User u=new User();
        u.setId(null);
        u.setEmail(email);
        u.setUsername(username);
        u.setPassword(password);
        u.setIsSecret("0");
        userDao.add(u);
    }

    @Override
    public User findUserByEmail(String email) {
        return userDao.findUserByEmail(email);
    }

    @Override
    public void resetPass(Integer id, String password) {
        User user = new User();
        user.setId(id);
        user.setPassword(password);
        userDao.update(user);
    }
}
